# -*- coding:utf8 -*-
'''
Created on 2011-5-22

@author: Vendar
'''

from PyQt4 import QtGui
import gdata.docs.service

class DocsData:
    def __init__(self):
        self.GData = gdata.docs.service.DocsService()
        self.UserName = ""
        self.Password = ""
        
    def Login(self,email,passwd):
        self.UserName = email
        self.Password = passwd
        try:
            self.GData.ClientLogin(email,passwd,source="GData Test")
        except Exception as e: #@UnusedVariable
            QtGui.QMessageBox.warning(None,'Warning','Login Failed!')
            return False
        return True
        
    def GetDocsTitles(self):
        docs = []
        feed = self.GData.GetDocumentListFeed()
        for entry in feed.entry:
            docs.append(entry.title.text)
        return docs
